<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', True);
session_start();

include("connect.php");

$username=mysql_real_escape_string($_POST["login"]);
$password=mysql_real_escape_string($_POST["password"]);
$email=mysql_real_escape_string($_POST["email"]);
$lista=$_POST["flags"];

$query = "SELECT * FROM `accounts` WHERE `login` = '{$username}'";
$result= mysql_query($query, $MySQL);
$num=mysql_num_rows($result);
if ($num > 0)
  
{
     /* Username already exists */
     echo 'Username already exists, please choose another one.';
	 exit;
 }  else {

if (empty($_POST['login']) and empty($_POST['password']) and empty($_POST['email'])) 
	{
		echo ('Fill everything on the registration form, dont leave it in blank.');
		exit;
	}	

 }
	
include ("connect.php");
$insert = "INSERT INTO `m4a_logon`.`accounts` (`login` ,`password`,`email`,`flags`)
VALUES ('".$username."','".$password."','".$email."','".$lista."')";
echo ('The account was created, you can now login! Wait 10 minutes before you login.');
mysql_query($insert, $MySQL);
?>